package com.balakitbbs.controller;

import org.springframework.beans.factory.annotation.Autowired; 
import java.util.*;               
import org.springframework.stereotype.Controller;               
import org.springframework.web.bind.annotation.PathVariable;               
import org.springframework.web.bind.annotation.RequestMapping;               
import org.springframework.web.servlet.ModelAndView;               
import com.balakitbbs.page.Page;               
import com.balakitbbs.page.SearchPageUtil;               
import com.balakitbbs.service.Bala_rebackpostService;
import com.balakitbbs.entity.Bala_rebackpost;
   /**
    * bala_rebackpost Controller类
    */ 
@Controller
public class Bala_rebackpostController{
	@Autowired
	private Bala_rebackpostService bala_rebackpostservice;

//增加回贴表
@RequestMapping("/page/{pageIndex}/{pageSize}/addBala_rebackpost")
public String addBala_rebackpost(Bala_rebackpost bala_rebackpost,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_rebackpost.setCdate(new Date());
	bala_rebackpost.setId(UUID.randomUUID().toString());
	bala_rebackpostservice.addBala_rebackpost(bala_rebackpost);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_rebackpost.do";
}


//删除回贴表
@RequestMapping("/page/{Id}/{pageIndex}/{pageSize}/delBala_rebackpost")
public String delBala_rebackpost(@PathVariable String Id,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_rebackpostservice.delBala_rebackpost(Id);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_rebackpost.do";
}


//修改回贴表
@RequestMapping("/page/{pageIndex}/{pageSize}/updateBala_rebackpost")
public String updateBala_rebackpost(Bala_rebackpost bala_rebackpost,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_rebackpost.setUdate(new Date());
	bala_rebackpostservice.updateBala_rebackpost(bala_rebackpost);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_rebackpost.do";
}


//查询回贴表
@RequestMapping("/page/{pageIndex}/{pageSize}/selectBala_rebackpost")
public ModelAndView selectBala_rebackposts(Bala_rebackpost bala_rebackpost,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	ModelAndView modelAndView = new ModelAndView();
	int selectBala_rebackpostCount = bala_rebackpostservice.selectBala_rebackpostsByPOJOCount(bala_rebackpost);
	Page page = new Page(pageIndex, pageSize, selectBala_rebackpostCount);
	SearchPageUtil spu = new SearchPageUtil();
	spu.setPage(page);
	modelAndView.addObject("data", bala_rebackpostservice.selectBala_rebackpostsByPojoPage(spu, bala_rebackpost));
	modelAndView.addObject("page", page);
	modelAndView.addObject("s", 1);
	modelAndView.addObject("po", new Bala_rebackpost());
	modelAndView.setViewName("/WEB-INF/page/bala_rebackpost.jsp");
	return modelAndView;
}

}

